package net.joey.httpclient.youku.impl;

import java.text.MessageFormat;

import net.joey.httpclient.youku.VideoAnalyService;
import net.joey.httpclient.youku.utils.JsonUtils;
import net.joey.httpclient.youku.utils.VideoUtils;
import net.sf.json.JSONObject;

public class VideoAnalyServiceTudouImpl implements VideoAnalyService{

	private String apiUrlPre = "http://api.tudou.com/v3/gw?method=repaste.info.get&format=json&appKey={0}&url={1}";
	private String appKey = "8784aaafa429aeef";
	private String titleJsonKey = "repasteInfo.itemInfo.title";
	private String outerPlayerUrlJsonKey = "repasteInfo.itemInfo.outerPlayerUrl";
	private String picUrlJsonKey = "repasteInfo.itemInfo.picUrl";
	
	@Override
	public Object analyVideo(String oriUrl) {
		JSONObject json = VideoUtils.getUrlJsonContent(MessageFormat.format(apiUrlPre, appKey,oriUrl),"UTF-8");
		if(null != json ){
			System.out.println("title="+JsonUtils.get(json, titleJsonKey));
			System.out.println("outerPlayerUrl="+JsonUtils.get(json, outerPlayerUrlJsonKey));
			System.out.println("picUrl="+JsonUtils.get(json, picUrlJsonKey));
			System.out.println(json.toString());
		}
		return null;
	}
	

}
